home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2001 March / macformat-101.iso / mac / Demos / SolidThinking 4 / Help / ehlpdht5.js < prev    next >
Encoding:
JavaScript  |  2000-09-06  |  8.6 KB  |  307 lines  |  [TEXT/dosa]

  1. /// Section Begin  - CCSSP DHTM (JavaScript 1.2)
  2. // eHelpÆ Corporation Dynamic HTML JavaScript 
  3. // Copyright© 1998-2000 eHelpÆ Corporation.All rights reserved.
  4. // Version=4.42
  5.  
  6. // Warning:Do not modify this file.It is generated by RoboHELPÆ and changes will be overwritten.
  7.  
  8.  
  9.  
  10. //Begin JavaScript libary for cross-platform positioning object.
  11. function CCSSP(){} // constructor of CCSSP class
  12.  
  13. CCSSP.strAgent = navigator.userAgent.toLowerCase(); 
  14. CCSSP.nAppVersion = parseInt(navigator.appVersion);
  15.  
  16. CCSSP.bIsWinOS = ((CCSSP.strAgent.indexOf("win") >= 0) || (CCSSP.strAgent.indexOf("16bit") >= 0));
  17. CCSSP.bIsMacOS = (CCSSP.strAgent.indexOf("mac") >= 0);
  18.  
  19. CCSSP.bIsIE = (navigator.appName.indexOf("Microsoft") >= 0);
  20. CCSSP.bIsIE4 = (CCSSP.bIsIE && (CCSSP.nAppVersion >= 4));
  21. CCSSP.bIsIE5 = (CCSSP.bIsIE4 && (CCSSP.strAgent.indexOf("msie 5") != -1) )
  22.  
  23. CCSSP.bIsNav = (navigator.appName.indexOf("Netscape") >= 0);
  24. CCSSP.bIsNav4 = (CCSSP.bIsNav && (CCSSP.nAppVersion >= 4));
  25.  
  26. CCSSP.GetObject = function( obj )
  27. {//convert object name string or reference into a valid object reference
  28.     if( typeof(obj) == "object" )
  29.         return obj;
  30.     else if( typeof(obj) == "string" && obj != "")
  31.     {
  32.         if( CCSSP.bIsNav4 )
  33.             return eval("document." + obj);
  34.         else
  35.             return eval("document.all." + obj);
  36.     }
  37.     else
  38.         return null;
  39. }
  40.  
  41. CCSSP.MoveObjectTo = function(obj, x, y)
  42. {//positioning an object at a specific pixel coordinate
  43.     if( CCSSP.bIsNav4 )
  44.         obj.moveTo(x,y);
  45.     else
  46.     {
  47.         obj.style.pixelLeft = x;
  48.         obj.style.pixelTop = y;
  49.     }
  50. }
  51.  
  52. CCSSP.MoveObjectBy = function(obj, dx, dy)
  53. {//moveing a object by x and/or y pixel
  54.     if( CCSSP.bIsNav4 )
  55.         obj.moveBy(dx,dy);
  56.     else
  57.     {
  58.         obj.style.pixelLeft += dx;
  59.         obj.style.pixelTop += dy;
  60.     }
  61. }
  62.  
  63. CCSSP.SetObjectBGColor = function(obj, color)
  64. {//set the background color of an object
  65.     if( CCSSP.bIsNav4 )
  66.         obj.bgColor = color;
  67.     else
  68.         obj.style.backgroundColor = color;
  69. }
  70.  
  71. CCSSP.ShowObject = function(obj, bShow)
  72. {// set the object to be visible or invisible
  73.     if( CCSSP.bIsNav4 )
  74.         obj.visibility = (bShow == true) ? 'show' : 'hide';
  75.     else
  76.         obj.style.visibility = (bShow == true) ? 'visible' : 'hidden';// when hidden, it still occupy some space.
  77. }
  78.  
  79. CCSSP.GetObjectLeft = function(obj)
  80. {// retrieve the x coordinate of a posionable object
  81.     if( CCSSP.bIsNav4 )
  82.         return obj.left;
  83.     else
  84.         return obj.style.pixelLeft;
  85. }
  86.  
  87. CCSSP.GetObjectTop = function(obj)
  88. {// retrieve the y coordinate of a posionable object
  89.     if( CCSSP.bIsNav4 )
  90.         return obj.top;
  91.     else
  92.         return obj.style.pixelTop;
  93. }
  94.  
  95. CCSSP.GetObjectContainLeft = function(obj)
  96. {// retrieve the x coordinate of a posionable object relative to it's parent element
  97.     if( CCSSP.bIsNav4 )
  98.         return obj.pageX;
  99.     else
  100.     {
  101.         if( obj == document.body )
  102.             return obj.clientLeft;
  103.         else
  104.             return obj.offsetLeft;
  105.     }
  106. }
  107.  
  108. CCSSP.GetObjectWindowLeft = function(obj)
  109. {// retrieve the x coordinate of a posionable object relative to browser window
  110.     if( CCSSP.bIsNav4 )
  111.         return obj.pageX;
  112.     else
  113.     {
  114.         var nOffsetWindowLeft = 0;
  115.         for(var element = obj; element; element = element.offsetParent)
  116.             nOffsetWindowLeft += CCSSP.GetObjectContainLeft(element);
  117.         return nOffsetWindowLeft;
  118.     }
  119. }
  120.  
  121. CCSSP.GetObjectContainTop = function(obj)
  122. {// retrieve the y coordinate of a posionable object relative to it's parent element
  123.     if( CCSSP.bIsNav4 )
  124.         return obj.pageY;
  125.     else
  126.     {
  127.         if( obj == document.body )
  128.             return obj.clientTop;
  129.         else
  130.             return obj.offsetTop;
  131.     }
  132. }
  133.  
  134. CCSSP.GetObjectWindowTop = function(obj)
  135. {// retrieve the y coordinate of a posionable object relative to browser window
  136.     if( CCSSP.bIsNav4 )
  137.         return obj.pageY;
  138.     else
  139.     {
  140.         var nOffsetWindowTop = 0;
  141.         for(var element = obj; element; element = element.offsetParent)
  142.             nOffsetWindowTop += CCSSP.GetObjectContainTop(element);
  143.         return nOffsetWindowTop;
  144.     }
  145. }
  146.  
  147. CCSSP.GetObjectHeight = function(obj)
  148. {// retrieve the height of a posionable object
  149.     if( CCSSP.bIsNav4 )
  150.         return obj.clip.height;
  151.     else
  152.         return obj.offsetHeight;
  153. }
  154.  
  155. CCSSP.GetObjectWidth = function(obj)
  156. {// retrieve the width of a posionable object
  157.     if( CCSSP.bIsNav4 )
  158.         return obj.clip.width;
  159.     else
  160.         return obj.offsetWidth;
  161. }
  162.  
  163. CCSSP.RegisterEventHandler = function( srcObj, rawEventName, funcHandler )
  164. { // to add the "funcHandler" as the "rawEventName" 's handler to the "srcObj" object,the original event handler will be combined
  165.     var oldHandler = "";
  166.     var oldInlineHandler = srcObj[rawEventName.toLowerCase()];
  167.     if( oldInlineHandler != null )
  168.     {
  169.         var functionDefinition = oldInlineHandler.toString();
  170.         var bodyStart = functionDefinition.indexOf( "{" );
  171.         var bodyEnd = functionDefinition.lastIndexOf( "}" );
  172.         if( bodyStart > 0 || bodyEnd > bodyStart )
  173.             oldHandler = functionDefinition.substr( bodyStart + 1, bodyEnd - bodyStart - 2 );
  174.     }
  175.     else if( CCSSP.bIsIE4 )
  176.     { //search for <SCRIPT> tag which define the event handler
  177.         for( var i = 0; i < document.scripts.length; i++ ) 
  178.         {
  179.             var script = document.scripts[i];
  180.             if( (script.htmlFor == srcObj.id || script.htmlFor == srcObj ) && script.event == rawEventName )
  181.             {
  182.                 oldHandler = script.innerHTML;
  183.                 break;
  184.             }
  185.         }
  186.     }
  187.     
  188.     if( oldHandler.indexOf(funcHandler) >= 0 )
  189.         return;// to prevent register the funtion twice.
  190.  
  191.     if( CCSSP.bIsNav4 ) // only "onload, onresize, onfocus" apply to window
  192.     {// other raw events will apply to layer
  193.         var noOn = rawEventName.substring(2, rawEventName.length);
  194.         if( typeof(noOn) == "string" && noOn.length > 3 )
  195.             srcObj.captureEvents( Event[noOn.toUpperCase()] );
  196.     }
  197.  
  198.     var newHandler = oldHandler;
  199.     if( newHandler.length == 0 )
  200.         newHandler = funcHandler;
  201.     else
  202.         newHandler += "; " + funcHandler;
  203.     srcObj[rawEventName.toLowerCase()] = new Function( newHandler );
  204. }
  205.  
  206. CCSSP.GetWindowHeight = function()
  207. {// retrieve the height of available content in browser window
  208.     if( CCSSP.bIsNav4 )
  209.         return window.innerHeight;
  210.     else
  211.         return document.body.clientHeight;
  212. }
  213.  
  214. CCSSP.GetWindowBottom = function()
  215. {// retrieve the bottom postion of browser window
  216.     if( CCSSP.bIsNav4 )
  217.         return window.outerHeight + window.pageYOffset;
  218.     else
  219.         return document.body.clientHeight + document.body.scrollTop;
  220. }
  221.  
  222. CCSSP.GetWindowWidth = function()
  223. {// retrieve the width of available content in browser window
  224.     if( CCSSP.bIsNav4 )
  225.         return window.innerWidth;
  226.     else
  227.         return document.body.clientWidth;
  228. }
  229.  
  230. CCSSP.GetWindowRight = function()
  231. {// retrieve the right postion of browser window
  232.     if( CCSSP.bIsNav4 )
  233.         return window.outerWidth + window.pageXOffset;
  234.     else
  235.         return document.body.clientWidth + document.body.scrollLeft;
  236. }
  237.  
  238. CCSSP.TrimString = function( objString, subtrim )
  239. {// to trim the "subtrim" in the beginning and ending of a string object
  240.     if( typeof(subtrim) != "string" || subtrim == null )
  241.         return objString;
  242.     var strHead = objString.substring(0, 1);
  243.     var strRear = objString.substring(objString.length-1, objString.length);
  244.     if( strHead != subtrim && strRear != subtrim )
  245.         return objString;
  246.     
  247.     var spacePos = objString.indexOf(subtrim);
  248.     if( spacePos < 0 )
  249.         return objString;
  250.     else if( spacePos == objString.length - 1 )
  251.         return objString.substring(0, spacePos);
  252.     else
  253.     {
  254.         var newString = objString.substring( spacePos + 1, objString.length);
  255.         return CCSSP.TrimString( newString, subtrim );
  256.     }
  257. }
  258.  
  259. CCSSP.TrimSpace = function( objString )
  260. {
  261.     var Trim1 = CCSSP.TrimString( objString, " ");
  262.     return CCSSP.TrimString( Trim1, "\'");
  263. }
  264.  
  265. CCSSP.GetEventElement = function( navEventObject )
  266. {// to get the element who fired the current event
  267.     if( CCSSP.bIsNav4 )
  268.         return navEventObject.target;
  269.     else
  270.         return event.srcElement;
  271. }
  272.  
  273. CCSSP.PrepareFilter = function( Obj )
  274. {//to prepare for making the filter work
  275.     Obj.style.filter = "";
  276.     if( Obj.style.width != "" || Obj.style.height != "" || Obj.style.position == "absolute" )
  277.         return;
  278.     Obj.style.height = CCSSP.GetObjectHeight(Obj);
  279. }
  280.  
  281. CCSSP.IsDescendant = function( progenitor, progeny )
  282. {
  283.     if( typeof(progeny) == "undefined" || progeny == null )
  284.         return false;
  285.     else if( progeny == progenitor )
  286.         return true; 
  287.     else if( progeny.id == progenitor.id ) 
  288.         return true; 
  289.     else if( progeny.parentElement == progenitor.parentElement )
  290.         return false;
  291.     else
  292.         return CCSSP.IsDescendant( progenitor, progeny.parentElement );
  293. }
  294.  
  295. CCSSP.IsTextTag = function( Obj )
  296. {
  297.     if( typeof( Obj.tagName ) == "undefined" )
  298.         return false;
  299.     return( Obj.tagName.indexOf("H") == 0 || Obj.tagName == "P" || 
  300.             Obj.tagName == "FONT" || Obj.tagName == "SPAN" );
  301. }
  302.  
  303. //End JavaScript libary for cross-platform positioning object.
  304.  
  305. /// Section End  - CCSSP DHTM (JavaScript 1.2)
  306.  
  307.